package com.shuai.mapper;


import com.shuai.annotation.AutoFill;
import com.shuai.entity.ProjectUserRelation;
import com.shuai.vo.ProjectUserRelationVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProjectUserRelationMapper {

    /**
     * 批量出入口味数据
     * */
    void insertBatch(List<ProjectUserRelation> relations);

    /**
     * 根据用户Id删除口味数据
     * */
    @Delete("delete from project_user where user_id  = #{userId}")
    void deleteByProjectUserId(Long userId);

    /**
     * 根据项目id集合批量删除关联的口味数据
     * */
    void deleteByIds(List<Long> Ids);


    @Select("SELECT pu.id, u.username , pu.user_id , u.name, pu.responsibility FROM project_user  pu left join  user u on pu.user_id = u.id  where pu.project_id = #{projectId}")
    List<ProjectUserRelationVO> getByProjectId(Long projectId);

    /**
     * 根据项目id删除关联的用户
     * @param projectId
     */
    @Delete("delete from project_user where project_id = #{projectId}")
    void deleteByProjectId(Long projectId);
}
